package base.chap3;

import java.util.Collections;

/**
 * ${DESCRIPTION}
 *
 * @author luoyalan
 * @date 2018/9/16
 */
public abstract class Person {
    private final int STUDENT_TAG = 3;
    private final int TEACHER_TAG = 4;

    private boolean tag;

    private int[] scores;

    public int getTagLength() {
        return scores == null ? 0 : scores.length;
    }

    public int getTag() throws Exception {
        switch (getTagLength()) {
            case STUDENT_TAG:
                return 0;
            case TEACHER_TAG:
                return 1;
            default:
                throw new Exception("unknow type");
        }

    }

    public int[] getScores() {
        return scores;
    }

    public void setScores(int[] scores) {
        this.scores = scores;
    }

    public int getAverageScore() {
        if (scores == null || scores.length < 1) {
            return 0;
        }
        int sum = 0;
        for (int i = 0; i < scores.length; i++) {
            sum += scores[i];
        }
        int average = sum / scores.length;
        return average;
    }

    abstract public void printPerson();
}
